package top.jx.util;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.text.SimpleDateFormat;
import java.util.TimeZone;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class PrintTimeUtils {
	public static final Log log=LogFactory.getLog(PrintTimeUtils.class);

	public static void printTime(long starTime) {
		long endTime = System.currentTimeMillis();
		System.out.println("用时："+(endTime - starTime)+"毫秒");
		SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");//初始化Formatter的转换格式。
		formatter.setTimeZone(TimeZone.getTimeZone("GMT+00:00"));
		String hms = formatter.format(endTime - starTime);
		System.out.println("耗时==" + hms);
	}
	public static long getProcessingTime(long starTime) {
		long endTime = System.currentTimeMillis();
		return endTime - starTime;
	}
	public static void printTime(long starTime, String desc) {
		long endTime = System.currentTimeMillis();
		System.out.println(desc+"  用时："+(endTime - starTime)+"毫秒");
		SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");//初始化Formatter的转换格式。
		formatter.setTimeZone(TimeZone.getTimeZone("GMT+00:00"));
		String hms = formatter.format(endTime - starTime);
		System.out.println(desc+"  耗时==" + hms);
	}


//	public static String writeFile(String string) throws IOException {
//		File temp = FileUtil.getTempFile(".text");
//		FileOutputStream writerStream = new FileOutputStream(temp);
//		BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(writerStream, "UTF-8"));
//		writer.write(string);
//		writer.close();
//		System.out.println(temp);
//		return temp.getPath();
//	}
}
